import { request } from '@/utils'

//发布文章请求
export function PublishApi(formData) {
    try {
        return request({
            url: '/geek/publish?draft=false',
            method: 'POST',
            data: formData
        })
    } catch (error) {
        console.log("error:", error)
    }
}

//获取全部文章请求  /  筛选文章请求
export function GetarticlesApi(params) {
    try {
        return request({
            url: '/geek/articles',
            method: 'GET',
            params
        })
    } catch (error) {
        console.log("error:", error)
    }
}

//获取一篇文章请求
export function GetarticleApi(id) {
    try {
        return request({
            url: `/geek/articles?id=${id}`,
            method: 'GET',
        })
    } catch (error) {
        console.log("error:", error)
    }
}

//删除文章一篇请求
export function DeleteArticleApi(id) {
    try {
        return request({
            url: `/geek/articles/${id}`,
            method: 'DELETE',
        })
    } catch (error) {
        console.log("error:", error)
    }
}

//更新文章一篇请求
export function UpArticleApi(formData,id) {
    try {
        return request({
            url: `/geek/publish/${id}?draft=false`,
            method: 'PUT',
            data: formData
        })
    } catch (error) {
        console.log("error:", error)
    }
}
